package cn.seifly.demo.web.setting;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.R;
import cn.seifly.demo.biz.system.dao.entity.SystemConfigDO;
import cn.seifly.demo.biz.system.service.SystemConfigService;
import cn.seifly.demo.biz.system.service.vo.SystemConfigVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.security.PermitAll;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 
 * @ClassName: SystemConfigController
 * @Description: TODO
 * @author: sxf
 * @date: 2025年11月09日 上午10:29:03
 */
@RestController
@RequestMapping(value = "adminapi/marketing/integral_config")
@Tag( name = "配置表" )
public class SystemConfigController extends BaseController {

    @Autowired
    private SystemConfigService systemConfigService;

    @GetMapping(value = "/edit_basics")
    @Operation(summary = "查询配置")
    @PermitAll
    public R<IPage<SystemConfigDO>> queryListByPage(@RequestParam("tab_id") Integer tabId) {

        SystemConfigVO systemConfigVO = new SystemConfigVO();
        systemConfigVO.setConfigTabId(tabId);
        IPage<SystemConfigDO> bizReturn = systemConfigService.queryListByParams(systemConfigVO);
        return R.ok(bizReturn);
    }

    @PostMapping(value = "create")
    @Operation(summary  = "新增保存")
    public AjaxResult create(@RequestBody SystemConfigVO req) {
        Integer result = systemConfigService.create(req);
        return success(result);
    }

    @PostMapping(value = "update")
    @Operation(summary  = "修改保存")
    public AjaxResult update(@RequestBody SystemConfigVO req) {
        Integer result = systemConfigService.update(req);
        return success(result);
    }

    @PostMapping(value = "delete")
    @Operation(summary  = "删除")
    public AjaxResult delete(@RequestBody SystemConfigVO req) {
        Integer result =  systemConfigService.delete(req);
        return success(result);
    }

    @PostMapping(value = "getDetail")
    @Operation(summary  = "查询详情")
    public AjaxResult getDetail(@RequestBody SystemConfigVO req) {
        SystemConfigDO result = systemConfigService.getDetail(req);
        return success(result);
    }
}